<head>
    <link href="${ctx}/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <link href="${ctx}/font-awesome/3.0.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="${ctx}/css/index.css" rel="stylesheet">
    <link href="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.css" rel="stylesheet">
    <script src="${ctx}/jquery/2.1.4/jquery.min.js"></script>
    <script src="${ctx}/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/bootstrap-table.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctx}/bootstrap-table/1.12.0/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="${ctx}/js/extends.js"></script>
    <script src="${ctx}/layui/layui.all.js"></script>
    <script src="${ctx}/js/util.js"></script>
    <link href="${ctx}/layui/css/layui.css" rel="stylesheet">

</head>
<body>
<title>统计</title>

<div class="container-fluid" style="padding-top: 10px">
    <div class="layui-inline">
        <label class="layui-form-label" style="width: 120px">起始时间</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="star" placeholder="请选择时间">
        </div>
    </div>
    <div class="layui-inline">
    <label class="layui-form-label" style="width: 120px">结束时间</label>
    <div class="layui-input-inline">
        <input type="text" class="layui-input" id="end" placeholder="请选择时间">
    </div>

    <button class="layui-btn" onclick="search()" >
        <i class="layui-icon">&#xe669;</i> 查询
    </button>
</div>
<div style="padding: 10px 20px">
     <form class="layui-form" style="width: 350px">
            <div >
                <select name="type" id="type" lay-verify="">
                    <option value="1">仅新增用户</option>
                    <option value="2">时间内用户</option>
                </select>
            </div>
        </form>




    <table class="table table-border table-bordered table-hover table-bg table-sort" id="layTable"
           lay-filter="tableFilter">

    </table>
</div>


</body>
<style>

</style>


<!--请在下方写此页面业务相关的脚本-->


<script type="text/javascript">
    var type = 1;
    var tableIns;
    var ids = "";
    var form;
    var table = "tb_module";
    var star="";
    var end="";
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        laydate.render({
            elem: '#star'
            , type: 'datetime'

        });
        laydate.render({
            elem: '#end'
            , type: 'datetime'

        });
    });
    layui.use('table', function () {
        tableIns = layui.table,
            form = layui.form;


        form.render();
        form.on('switch(sexDemo)', function (obj) {
            // layer.tips(this.value + ' ' + this.name + '：'+ obj.elem.checked, obj.othis);
            if (obj.elem.checked) {
                commonenable(this.value, 'False');
            } else {
                commonenable(this.value, 'true');
            }

        });
        tableIns.on('checkbox(tableFilter)', function (obj) {
            var checkStatus = tableIns.checkStatus('dataTableId');
            var dataList = checkStatus.data;
            if (dataList != null && dataList.length > 0) {

                for (var i = 0; i < dataList.length; i++) {
                    ids += dataList[i].id + ",";
                }
            }
        });


        $("#multiDelete").click(function () {
            deleteId(ids)
        });

        tableIns.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') {
                layer.msg('ID：' + data.id + ' 的查看操作');
            } else if (obj.event === 'del') {
                if (data.has_deleted == 1) {
                    layer.msg('已删除，不可进行该操作!', {icon: 1, time: 1000});
                    return;
                }
                layer.confirm('真的删除行么', function (index) {
                    deleteId(data.id)
                    layer.close(index);
                });
            } else if (obj.event === 'edit') {
                if (data.has_deleted == 1) {
                    layer.msg('已删除，不可进行该操作!', {icon: 1, time: 1000});
                    return;
                }
                layer_show("轮播图修改", "/application/moduleSave?id=" + data.id, "550", "650");
                parent.search();
            } else if (obj.event === 'save') {
                $.ajax({
                    url: "/application/sortSave",    //请求的url地址
                    dataType: "json",   //返回格式为json
                    async: true,//请求是否异步，默认为异步，这也是ajax重要特性
                    data: {table: table, id: data.id, sort: data.sort},    //参数值,键值对
                    type: "post",   //请求方式
                    beforeSend: function () {
                        //请求前的处理
                    },
                    success: function (req) {
                        //请求成功时处理
                        if (req.success) {
                            showmsg(req.message);
                            search();
                        } else {
                            layer.msg(req.message)
                        }
                    },
                    complete: function () {
                        //请求完成的处理
                    },
                    error: function () {
                        //请求出错处理
                        layer.msg("请重试！若在失败请联系管理员")
                    }
                });
            }
        });
    });

    function search() {
        type = $("#type").val();
        star = $("#star").val();
        end = $("#end").val();

        tableIns.render({
            elem: '#layTable'
            ,
            url: '/statistics/member/statistics'
            ,
            method: 'POST'
            ,
            where: {type: type,starTime:star,endTime:end},
            id: 'dataTableId'
            ,
            totalRow:true
            ,
            toolbar:true
            ,

            cols: [[
                {
                    field: 'appStore',
                    title: '渠道',
                    width: 160,
                    align: 'center',
                    sort: true ,
                    totalRowText:'总计'

                }
                , {
                    field: 'count',
                    title: '用户数',
                    width: 160,
                    align: 'center',
                    sort: true,
                    totalRow: true
                }
                , {

                    field: 'myMoney',
                    title: '用户带来的收益',
                    width: 160,
                    align: 'center',
                    sort: true,
                    totalRow: true
                }

                , {
                    field: 'userMoney',
                    title: '用户收益',
                    width: 160,
                    align: 'center',
                    sort: true,
                    totalRow: true
                }, {
                    field: 'brandMoney',
                    title: '渠道收益',
                    width: 160,
                    align: 'center',
                    sort: true,
                    totalRow: true
                }, {
                    field: 'zyMoney',
                    title: '自营收益',
                    width: 160,
                    align: 'center',
                    sort: true,
                    totalRow: true
                }, {
                    field: 'userOutLay',
                    title: '已提现',
                    width: 160,
                    align: 'center',
                    sort: true,
                    totalRow: true
                }, {
                    field: 'apru',
                    title: 'apru',
                    width: 160,
                    align: 'center',
                    sort: true,
                    templet: function (data) {
                        return (  data.myMoney-data.userMoney) / data.count
                    }
                }


            ]]
            ,
            page: false
        });
    }


    function showmsg(msg) {
        layer.msg(msg)
    }


</script>
<!--/请在上方写此页面业务相关的脚本-->
